Skip to content

[Slider] Fix overlapping slider thumbs stuck at min or max #1732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 17, 2025

Conversation

mj12albert
Copy link
Member

@mj12albert mj12albert commented Apr 16, 2025

Fixes #1731

Demo: https://codesandbox.io/p/sandbox/fast-glitter-7tck3z

When 2 or more thumbs overlap in the same position they can be dragged apart now

@mj12albert mj12albert added the component: slider This is the name of the generic UI component, not the React module! label Apr 16, 2025
@@ -129,8 +129,6 @@ export function useSliderThumb(parameters: useSliderThumb.Parameters): useSlider
}[orientation]]: `${percent}%`,
[isVertical ? 'left' : 'top']: '50%',
transform: `translate(${(isVertical || !isRtl ? -1 : 1) * 50}%, ${(isVertical ? 1 : -1) * 50}%)`,
// So the non active thumb doesn't show its label on hover.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only relevant to ValueLabel from @mui/base

Copy link

netlify bot commented Apr 16, 2025

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0b226a5
🔍 Latest deploy log https://app.netlify.com/sites/base-ui/deploys/68009d83019d4f000858f6cb
😎 Deploy Preview https://deploy-preview-1732--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@mj12albert mj12albert force-pushed the fix/stuck-overlapping-slider-thumb branch from 649074a to 0f4c023 Compare April 16, 2025 16:47
@mj12albert mj12albert marked this pull request as ready for review April 16, 2025 17:09
@atomiks
Copy link
Contributor

atomiks commented Apr 16, 2025

I think whichever one was used last should be the one that's on top? e.g. I'd expect max to be on top here but it flips to the min

Screen.Recording.2025-04-17.at.9.44.33.am.mov

@mj12albert
Copy link
Member Author

mj12albert commented Apr 17, 2025

I think whichever one was used last should be the one that's on top?

Actually assuming all the thumbs have equal z-index, it seems better to consider the right-most thumb (closest to max) to be "closest" based on the natural stacking order. The exception is when they overlap at max, drags need to move the left-most thumb first, or it will block other thumbs from moving, what do you think @atomiks ?

slider-overlap.mov

Copy link
Contributor

@atomiks atomiks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also work fine with RTL right?

@mj12albert
Copy link
Member Author

This should also work fine with RTL right?

Yep ~ here it's only comparing values vs each other and min/max so direction and orientation don't matter

@mj12albert mj12albert merged commit 5c11ddf into mui:master Apr 17, 2025
22 checks passed
@mj12albert mj12albert deleted the fix/stuck-overlapping-slider-thumb branch April 17, 2025 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Slider] Thumbs that overlap at max cannot be dragged
2 participants